/*
 * Created: Author: Aléx Carvalho / Date: Jan 23, 2015
 * 
 * Changed: $Author: ac280593@gmail.com $ / $Date: 2015-05-13 10:23:31 -0300 (qua, 13 mai 2015) $
 */
package com.cpm.entities.id;

import com.cpm.entities.Indicator;
import java.sql.Date;
import java.time.LocalDate;
import java.util.Objects;

public class CompetenceId implements Id<CompetenceId> {

    private Indicator indicator;

    private Date competencePeriod;

    public CompetenceId() {
    }

    public CompetenceId(Indicator indicator, LocalDate period) {
        this.indicator = indicator;
        this.competencePeriod = Date.valueOf(period);
    }

    @Override
    public CompetenceId getId() {
        return this;
    }

    @Override
    public String toString() {
        return "Indicator: " + indicator.toString() + " - " + competencePeriod.toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }

        if (obj instanceof CompetenceId) {

            CompetenceId other = (CompetenceId) obj;

            return indicator.equals(other.indicator) && competencePeriod.equals(other.competencePeriod);
        }

        return false;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 13 * hash + Objects.hashCode(this.indicator);
        hash = 13 * hash + Objects.hashCode(this.competencePeriod);
        return hash;
    }
}
